var name = 'tom'

export function fn() {
  console.log(name)
}
export const a = 3


/* 

const {fn, a} = (() => {
var name = 'tom'
function fn() {
  console.log(name)
}
const a = 3

return {
  fn,
  a
}

})()
*/
// 高阶函数: 参数是函数 / 返回值是函数
function debounce(callback, time) {
  let timer 
  return function (event) {
    clearTimeout(timer)

    timer = setTimeout(() => {
      callback.call(this, event)
    }, time);
  }
}


function fn(event) {
  // 处理事件 => 发请求
}

div.onclick = debounce(fn, time)